/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.fieo.sgee.model;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 * Classe Persistente para controlar a entidade Usuário
 * @author rbueno
 */
@Entity
@Table(name = "usuarios")
@NamedQueries({
    @NamedQuery(name = "User.findByLogin", query = "SELECT u FROM User u WHERE u.login = :login"),
    @NamedQuery(name = "User.findBySenha", query = "SELECT u FROM User u WHERE u.password = :password"),
    @NamedQuery(name = "User.findByTipo", query = "SELECT u FROM User u WHERE u.type = :type"),
    @NamedQuery(name = "User.findByDataCriacao", query = "SELECT u FROM User u WHERE u.created_at = :created_at"),
    @NamedQuery(name = "User.findByDataModificacao", query = "SELECT u FROM User u WHERE u.updated_at = :updated_at"),
    @NamedQuery(name = "User.login", query = "SELECT u FROM User u Where u.login = :login and u.password = :password")
})
public class User implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Basic(optional = false)
    @Column(name = "login")
    private String login;
    @Basic(optional = false)
    @Column(name = "senha")
    private String password;
    @Basic(optional = false)
    @Column(name = "tipo")
    private String type;
    @Basic(optional = false)
    @Column(name = "data_criacao")
    @Temporal(TemporalType.TIMESTAMP)
    private Date created_at;
    @Basic(optional = false)
    @Column(name = "data_modificacao")
    @Temporal(TemporalType.TIMESTAMP)
    private Date updated_at;

    public User() {
        this.created_at = new Date();
        this.updated_at = new Date();
    }

    public User(String login, String password, String type) {
        this.login = login;
        this.password = password;
        this.type = type;
        this.created_at = new Date();
        this.updated_at = new Date();
    }

    public Date getCreated_at() {
        return created_at;
    }

    public String getLogin() {
        return login;
    }

    public void setLogin(String login) {
        this.login = login;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(char[] password) {
        this.password = new String(password);
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public Date getUpdated_at() {
        return updated_at;
    }

    public Integer getId() {
        return id;
    }
}
